// pages/Ranking/Ranking.js
var Session = require('../../vendor/qcloud-weapp-client-sdk/lib/session.js');
var config = require('../../config.js');
var commons = require('../../commons.js');
var qcloud = require('../../vendor/qcloud-weapp-client-sdk/index');
var register = require('../../template/register/register.js');
var utils = require('../../vendor/qcloud-weapp-client-sdk/lib/utils.js');
var index = {

  /**
   * 页面的初始数据
   */
  data: {
    ShareVideoData:"",
    roomId:""
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    utils.showLoading();
    this.setData({
      roomId: options.detailID
    })
    this.ShareVideo();
  },
  ShareVideo:function(roomId){
    var that =this;
    qcloud.request({
      login: true,
      url: config.service.ShareVideoUrl,
      data: {
        'room_id': that.data.roomId
      },
      header: {
        'content-type': 'application/json' // 默认值
      },
      success(res) {
        that.setData({
          ShareVideoData: res.data.data
        })
      },
      fail: function (res) {
        utils.showError('请求出错')
      },
      complete: function () {
        setTimeout(function () {
          wx.hideLoading();
          wx.stopPullDownRefresh();
        }, 500)
      }
    });

  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    this.ShareVideo();
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    return {
      title: '小城市live',
      path: '/pages/index/index',
      success: function () {
        utils.showSuccess("转发成功");
      }
    };
  }
};
var data = Object.assign(index.data, register.data);
var page = Object.assign(index, register);
page.data = data;
Page(page);